home *** CD-ROM | disk | FTP | other *** search
- Path: ludens.elte.hu!genie
- From: genie@ludens.elte.hu
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Removing a patch -A POSSIBLE SOULTION
- Message-ID: <1996Feb5.162318.23977@ludens>
- Date: 5 Feb 96 16:23:18 +0200
- References: <1996Jan29.141204.23597@ludens> <1177.6603T1212T240@stud.cs.uit.no>
- Organization: Eotvos University, Budapest, Hungary
-
- >>The code for the patch which is SetFunctioned somewhere looks like this:
- >
- >>PatchMan: addq #1,UseCount ;how many tasks using this patch?
- > ^^^^^^^^^^^^^^^^^
- > This does really not help a lot if you want your progam to be 100% safe.
- > Still, it does decrease the chance of crashes. The problem is that a process
- > switch could (at least in teory) occur right after the PC was loaded with the
- > address of your routine, but before actually executing the first instruction
- > in it.
-
- I don't think it's a problem, because the PatchMan routine stays in memory
- "forever", which is a really tiny piece of code, but I can safely free up
- the memory allocated for the main patch code (to which this PatchMan later
- gives control). Suppose the scheduler stops the PathcMan routine just before
- it could increase UseCount, and so UseCount stays zero. If in this moment the
- patch is removed, it is set inactive, and when PatchMan gets the CPU again,
- it won't let the patchcode run. Rescheduling cannot occur while setting the
- patch into inactive state due to the Forbid()den state of the removal handler.
- Consider this!
-
- --------------------------------------------------------------------------------
- /// Kertai 'Genie' Gabor | PGP fingerprint:
- /// from Eotvos Lorad University of Sciences | 32 36 96 9A 15 61 03 98
- \\\/// Budapest 1038, Eszak u. 39., Hungary | 7D D3 29 14 84 27 78 AC
- \XX/ E-mail: genie@ludens.elte.hu | Public key via finger...
- --------------------------------------------------------------------------------
-